<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<style>
<!--
.searchContent td label{
width:50px;
}
-->
</style>
<form id="pagerForm" method="post" action="#rel#">
	<input type="hidden" name="pageNum" value="${currentPage }" /> 
	<input type="hidden" name="numPerPage" value="${numPerPage}" /> 
	<input type="hidden" name="orderField" value="${param.orderField}" /> 
	<input type="hidden" name="orderDirection" value="${param.orderDirection}" />
	<input type="hidden" value="${csrfToken}" name="CSRFToken">
</form>
<div class="pageHeader">
	<form rel="pagerForm" onsubmit="return navTabSearch(this);"	action="insideUser_list.action" method="post">
		<div class="searchBar nowrap">
			<p>
				<label>姓名或手机号:</label>
				<input type="text" name="isuName" value="${isuName}" maxlength="20"/>
			</p>
			<p>
				<label>用户组：</label>
				<select
					id="groupList" 
					name="isuGroupCode" 
					class="combox"
					ref="roleList"
					refUrl="userRole_getRoleList2.action?usgCode={value}">
					<option value="">---所有用户组---</option>
					<c:forEach items="${userGroupList}" var="group">
						<option ${isuGroupCode==group.usgCode?"selected":""}  value="${group.usgCode }">${group.usgName}</option>
					</c:forEach>
				</select>
			</p>
			<p>
				<label>角&nbsp;&nbsp;色：</label>
				<select name="isuRoleCode" id="roleList" class="combox">
					<option value="" >---所有角色---</option>
					<c:forEach items="${userRoleListByGroup }" var="role">
						<option ${isuRoleCode==role.usrCode?"selected":""} value="${role.usrCode}">${role.usrName}</option>
					</c:forEach>
				</select>
			</p>
			<p>
				<label>部&nbsp;&nbsp;门：</label>
				<select class="combox" name="deptCode">
					<option value="">---所有部门---</option>
					<c:forEach items="${departmentList }" var="dept">
						<option ${deptCode==dept.deptCode?"selected":""} value="${dept.deptCode}">${dept.deptName}</option>
					</c:forEach>
					
				</select>
			</p>
			<div class="subBar">
				<ul>
					<li>
					<div class="buttonActive"><div class="buttonContent"><button type="submit">检索</button></div></div>
						</li>
				</ul>
			</div>
		</div>
	</form>
</div>

<div class="pageContent">
	<div class="panelBar">
		<c:choose>
			<c:when test="${empty errorMsg}">
				<ul class="toolBar">
					<li><a class="add" href="insideUser_addUI.action" rel="insideUser_addUI"  target="navTab" title="新增内部用户" ><span>新增</span></a></li>
					<li class="line">line</li>
					<li><a class="edit" href="insideUser_editUI.action?isuId={user_id}" rel="insideUser_editUI"  target="navTab" warn="请选择一个用户" title="修改内部用户"><span>修改</span>	</a></li>
					<%-- 禁用用户删除功能
					<li class="line">line</li>
					<li><a class="delete" href="insideUser_delete.action?isuId={user_id}"  target="ajaxTodo"   title="确实要删除这些记录吗?">	<span>删除</span></a></li>
					 --%>
					<li class="line">line</li>
					<li><a class="look" href="insideUser_show.action?isuId={user_id}&CSRFToken=${csrfToken}" rel="insideUser_show"  target="navTab" warn="请选择一个用户" title="查看内部用户"><span>查看</span>	</a></li>
					<li class="line">line</li>
					<li><a id="insideUser_setFlagLink" class="icon" href="insideUser_updateFlag.action?isuId={user_id}&CSRFToken=${csrfToken}" target="ajaxTodo" title="确实要停用/启用该内部用户吗?"><span id="insideUser_setFlagText">停用/启用</span></a></li>
					<li class="line">line</li>
					<li><a class="edit" href="insideUser_resetPwd.action?isuId={user_id}&CSRFToken=${csrfToken}"   target="ajaxTodo"  title="确定要重置该用户密码吗？"><span>密码重置</span>	</a></li>
					<li class="line">line</li>
				</ul>
			</c:when>
			<c:otherwise>
				<div style="line-height: 25px;margin-right: 20px;font-weight: normal;text-align: center;color: red;">
					${errorMsg }
				</div>
			</c:otherwise>
		</c:choose>
	
	</div>
	
	<c:if test="${empty errorMsg }">
	<table class="table" width="100%" layoutH="118">
		<thead>
			<tr>
				<th width="" align="center">序号</th>
				<th width="" >姓名</th>
				<th width="" >性别</th>
				<th width="" >手机号</th>
				<th width="" >邮箱</th>
				<th width="" >用户组</th>
				<th width="" >角色</th>
				<th width="" >部门</th>
				<th width="" >状态</th>
			</tr>
		</thead>
		<tbody>
			<c:forEach items="${recordList}" var="user" varStatus="status">
			<tr target="user_id" rel="${user.isuId }" onclick="insideUser_doSelect(this)">
				<td>${(status.index+1) + (currentPage-1) * numPerPage}
				<input id="insideUser_flag_${status.index }" type="hidden" value="${user.isuStatusFlag }">
				</td>
				<td>${user.isuName }</td>
				<td>
				<c:choose>
					<c:when test="${user.isuSex==1 }">
					男
					</c:when>
					<c:when test="${user.isuSex==2 }">
					女
					</c:when>
					<c:otherwise>
					未知
					</c:otherwise>
				</c:choose>
				</td>
				<td>${user.isuPhone }</td>
				<td>${user.isuEmail }</td>
				 <td>
				 	<c:forEach var="group" items="${userGroupList}">
	 					<c:if test="${group.usgCode==user.isuGroupCode }">
							${group.usgName }
						</c:if>
					</c:forEach>
				 </td>
				<td>
					<c:forEach var="userRole" items="${userRoleList}">
	 					<c:if test="${userRole.usrCode==user.isuRoleCode }">
							${userRole.usrName }
						</c:if>
					</c:forEach>
					<c:if test="${user.managerFlag eq '1'}"><span style="color:red;">(大区经理)</span></c:if>
				</td>
				<td>
					<c:forEach var="dept" items="${departmentList}">
 					<c:if test="${dept.deptCode==user.deptCode }">
 						<c:if test="${fn:length(dept.deptName)>0}">
 							${fn:substringAfter(dept.deptName,"┣")}
 						</c:if>
						
					</c:if>
				</c:forEach>
				</td>
				<td>
					<a style="color:${user.isuStatusFlag==1?"green":"red"};text-decoration:none ;" >
						${user.isuStatusFlag==1?"正常":"停用" }
					</a>
				</td>
				<%--
				<td>
					<a style="cursor:pointer;color:${user.isuStatusFlag==1?"green":"red"};" 
						title="点击${user.isuStatusFlag==1?"停用":"启用" }"
						target="ajaxTodo"
						href="insideUser_updateFlag.action?isuId=${user.isuId}"
						>
						${user.isuStatusFlag==1?"正常":"停用" }
					</a>
				</td>
				 --%>
				<%--
				<td>
					<a title="删除" target="ajaxTodo" href="demo/common/ajaxDone.html?id=xxx" class="btnDel">删除</a> 
					<a title="编辑" target="navTab" href="demo_page4.html?id=xxx" class="btnEdit">编辑</a>
					<a class="btnAdd">btnAdd</a>
					<a class="btnDel">btnDel</a>
					<a class="btnView">btnView</a>
					<a class="btnEdit">btnEdit</a>
					<a class="btnSelect">btnSelect</a>
					<a class="btnInfo">btnInfo</a>
					<a class="btnAssign">btnAssign</a>
					<a class="btnLook">btnLook</a>
					<a class="btnAttach">btnAttach</a>
					
				</td>
				 --%>
			</tr>
			</c:forEach>
		</tbody>
	</table>
	
	<%@ include file="/WEB-INF/jsp/public/panelBar.jsp"%>	
	</c:if>
</div>
<script type="text/javascript">
function insideUser_doSelect(obj){
	var flagText = $("#insideUser_setFlagText", navTab.getCurrentPanel());
	var flagLink = $("#insideUser_setFlagLink", navTab.getCurrentPanel());
	var falgValue = $("#insideUser_flag_"+obj.rowIndex, navTab.getCurrentPanel()).val();
	if(falgValue==0){
		flagText.text("启用");
		flagLink.attr("title","确定要启用该内部用户吗？")
		flagLink.attr("class","icon-ok");
		
	}else if(falgValue==1){
		flagText.text("停用");
		flagLink.attr("title","确定要停用该内部用户吗？")
		flagLink.attr("class","icon");
	}else{
		flagText.text("停用/启用");
		flagLink.attr("class","icon");
	}
}
</script>